package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController     //@ResponseBody  +  @Controller
public class DishController {

    //依赖注入service层
    @Autowired
    private DishService dishService;

    /**
     * 查询菜品列表
     * Request URL: http://localhost:8081/dish/list?categoryId=1397844303408574465&status=1
     * Request Method: GET
     */
    @GetMapping("/dish/list")
    public ResultInfo findList(String categoryId,Integer status){   //接收普通参数
        //1.调用service层
        List<Dish> dishList = dishService.findList(categoryId,status);
        //2.返回响应
        return ResultInfo.success(dishList);
    }
}
